TextAnimation
Base classes
| Name |
Children |
Inherits |
PropertyAnimation prettyqt.core.propertyanimation Animates Qt properties. |
|
|
⋔ Inheritance diagram
graph TD
381516958["animations.TextAnimation"]
4280009853["core.PropertyAnimation"]
2400666939["core.VariantAnimationMixin"]
565069530["core.AbstractAnimationMixin"]
3227531497["core.ObjectMixin"]
2751680898["builtins.object"]
3508266353["QtCore.QPropertyAnimation"]
2420859519["QtCore.QVariantAnimation"]
2133980439["QtCore.QAbstractAnimation"]
3984060476["QtCore.QObject"]
37984305["Shiboken.Object"]
4280009853 --> 381516958
2400666939 --> 4280009853
565069530 --> 2400666939
3227531497 --> 565069530
2751680898 --> 3227531497
3508266353 --> 4280009853
2420859519 --> 3508266353
2133980439 --> 2420859519
3984060476 --> 2133980439
37984305 --> 3984060476
2751680898 --> 37984305
🛈 DocStrings
Bases: PropertyAnimation
Source code in prettyqt/animations/textanimation.py
| class TextAnimation(core.PropertyAnimation):
ID = "text"
def __init__(
self,
start: datatypes.VariantType | None = None,
end: datatypes.VariantType | None = None,
duration: int = 1000,
easing: core.easingcurve.TypeStr = "in_out_sine",
fmt: NameStr = "html",
mask: str = "{text}",
parent: core.QObject | None = None,
):
self._fmt = fmt
self._mask = mask
super().__init__(parent)
self._child_anim = core.VariantAnimation()
self._child_anim.valueChanged.connect(self.updateCurrentValue)
self.set_easing(easing)
self.set_duration(duration)
if start is not None:
self._child_anim.set_start_value(start)
if end is not None:
self._child_anim.set_end_value(end)
self.setStartValue("")
self.setStartValue("")
def start(self, *args, **kwargs):
self._child_anim.start(*args, **kwargs)
super().start(*args, **kwargs)
# TODO: also do stop etc.
def set_start_value(self, value: datatypes.VariantType):
self._child_anim.set_start_value(value)
def set_end_value(self, value: datatypes.VariantType):
self._child_anim.set_end_value(value)
def set_easing(self, easing: core.easingcurve.TypeStr | core.QEasingCurve.Type):
super().set_easing(easing)
self._child_anim.set_easing(easing)
def set_duration(self, duration: int):
super().setDuration(duration)
self._child_anim.set_duration(duration)
def updateCurrentValue(self, value: datatypes.VariantType):
match value:
case None:
return None
case gui.QColor():
color = gui.Color(value)
text = color.get_name(self._fmt) if self._fmt else color.toString()
value = self._mask.format(text=text)
case int() | float():
value = self._mask.format(text=str(value))
case core.QPoint() | core.QPointF():
return f"{value.x()}, {value.y()}"
case core.QSize() | core.QSizeF():
return f"{value.width()}, {value.width()}"
logger.debug(value)
super().updateCurrentValue(value)
return None
|
:fa-brands-github: Show source on GitHub